<!DOCTYPE html>
<html lang="zh">

<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta http-equiv="Access-Control-Allow-Origin" content="*">
	<title>宇成建筑-设置新密码</title>
	<link rel="stylesheet" href="../statics/plugins/layui/css/layui.css" />
	<link rel="stylesheet" href="../statics/css/font.css">
	<link rel="stylesheet" href="../statics/css/login.css">
</head>

<body>
	<header>
		<div class="layui-row">
			<div class="layui-col-xs2 logo">
				<img src="../statics/images/logo.png" alt="" />
				<span></span>
			</div>
			<div class="layui-col-xs10 title">
				<span>君正方华建筑施工劳务企业管理系统</span>
			</div>
		</div>
	</header>
	<main>
		<div class="main">
			<div class="layui-row title">
				<div class="layui-col-xs12">
					<h2>设置新密码</h2>
				</div>
			</div>
			<div class="input-box">
				<div class='input-width'>
					<i class='iconfont'>&#xe614;</i>
					<input type="password" placeholder="新密码" id='newPwd'>
				</div>
				<div class='input-width'>
					<i class='iconfont password'>&#xe61a;</i>
					<input type="password" placeholder="确认密码" id='truePwd'>
				</div>
			</div>
			<div class="input-box login">
				<div class='input-width'>
					<button class="layui-btn layui-btn-normal">确认</button>
				</div>
			</div>
		</div>
	</main>
	<footer>
		<p>天津市君正方华科技有限公司 版权信息：xxxxxxxxxxxxx 备案号：津ICP备18000734号</p>
	</footer>
	<script src='../statics/plugins/layui/layui.js'></script>
	<script src='../statics/plugins/jQuery-3.2.1/jquery-3.2.1.min.js'></script>
	<script src='../statics/js/public.js'></script>
	<script>
		$(function () {
			localStorage.clear();
		})
		layui.use(['layer'], function () {
			var layer = layui.layer;
			$('body').on('click', '.login button', function() {
				if($('#newPwd').val() == '' || $('#newPwd').val() == null || $('#newPwd').val() == undefined || $('#newPwd').val() == " ") {
					layer.msg('请输入新密码！');
				} else if($('#truePwd').val() == '' || $('#truePwd').val() == null || $('#truePwd').val() == undefined || $('#truePwd').val() == " ") {
					layer.msg('请确认密码！');
				} else if($('#newPwd').val() != $('#truePwd').val()) {
					layer.msg('两次输入的密码不一致！');
				} else {
					var password = $('#newPwd').val();
					var confirmPassword = $('#truePwd').val();
					$.ajax({
						url: url + '/auth/resetPwd',
						type: "post",
						data: {
							token: localStorage.getItem('token'),
							password: password,
							confirmPassword: confirmPassword
						},
						dataType: "json",
						success: function(r) {
							if(r.code == 100000) {
								layer.msg('密码设置成功！');
                                setTimeout(function(){
                                    window.location.href='indexPage.html';
                                },1000)
							} else {
								layui.use('layer', function() {
									var layer = layui.layer;
									layer.open({
										type: 1,
										title: "修改密码",
										area: ["40%", '30%'],
										content: `<p class='one_p'>${r.msg}</p>`,
										btn: ['关闭'],
										skin: 'my-skin',
									})
								});
							}
						}
					})
				}
			})
		})
	</script>
</body>

</html>